Код:
//=============================================================================
// learning_point.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Плагин добавляет систему получения очков обучения при поднятии уровня.
* @autor AppleDog
* @help Плагин автоматически добавляет 10 очков обучения всем участникам партии при
* повышении уровня.
* Вы можете сменить это количество для каждого персонажа, добавив в поле заметок
* строчку <learning_point_for_level:N>,
* где N количество очков обучения, получаемых за уровень.
*
* Так же у плагина есть четыре команды:
* 1) "Add learning point for all" - добавляет очки обучения для всей партии.
* Сколько добавить указывается в аргументе "Learning Points"
* 2) "Add learning point for actor" - добавляет очки обучения для одного персонажа.
* Сколько добавить указывается в аргументе "Learning Points", а персонаж
* в аргументе "Actor ID" по номеру в базе данных
* 3) "open_skill_window" - Скиллы и их цены должны передаваться через ; без пробелов
* например если ввести 1;4;8 и 5;5;4 Значит, что скилл 1 и 4 будет стоить по 5, а 8 будет стоить 4
* 4) "open_characterisctic_window" - Навыки, их цены и на сколько увеличить должны передаваться через ; без пробелов
* например если ввести luc;atk и 5;4 и 5;1 Значит, что удача и атака будет стоить по 5 и 4, а увеличиваться на 5 и 1 соответственно
* Названия скиллов можно взять из окна ввода формул в меню навыков
*
* @command add_learning_points_for_all
* @text Add learning point for all
* @desc Добавляет очки обучения для всей партии
* @arg points
* @text Learning Points
* @ desc Количество добавляемых очков
*
*
* @command add_learning_points_for_actor
* @text Add learning point for actor
* @desc Добавляет очки обучения для одного
* @arg points
* @text Learning Points
* @ desc Количество добавляемых очков
* @arg actor_id
* @text Actor ID
* @ desc ID актёра, которому нужно добавить очки
*
* @param name_learning_points
* @desc Отоброжаемое название очков, получаемых за уровень
* @default Очки обучения
* @param standart_learning_point
* @desc Очи обучения по умолчанию
* @default 10
*
* @command open_skill_window
* @text open_skill_window
* @desc Открывает окно прокачки навыков.
* @arg skills
* @arg cost_skills
* @text Skills
* @text Cost Skills
*
* @command open_characterisctic_window
* @text open_characterisctic_window
* @desc Открывает окно прокачки статов.
* @arg characterisctics
* @arg cost_characterisctics
* @arg val_characterisctics
* @text Characterisctics
* @text Cost Characterisctics
* @text Value Characterisctics
*
*/
////LEARNING POINT
var parameters = PluginManager.parameters('learning_point');
var name_learning_points = String(parameters['name_learning_points']);
var _selected_actor = null;
var skills_for_learning = [];
var cost_skills_for_learning = [];
var val_skills_for_learning = [];
var type_upgrade = 0;///0 - skill, 1 - characteristic
var characteristic_name = {
'mhp':0,
'mmp':1,
'atk':2,
'def':3,
'mat':4,
'mdf':5,
'agi':6,
'luk':7,
}
const ny_initMembers = Game_Actor.prototype.initMembers;
Game_Actor.prototype.initMembers= function() {
ny_initMembers.call(this);
this._learning_points = 0;
this._learning_points_for_level = Number(parameters['standart_learning_point']);;
};
const ny_game_actor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function(actorId) {
ny_game_actor_setup.call(this, actorId);
const actor = $dataActors[actorId];
this.ny_note = actor.note;
var _index_note = this.ny_note.indexOf("<learning_point_for_level:");
var _learning_points_actor = "";
for (let i = _index_note+26; i < this.ny_note.length; i++){
if(this.ny_note[i] == ">"){
break;
}
_learning_points_actor+=this.ny_note[i];
}
if(_learning_points_actor!=""){this._learning_points_for_level = Number(_learning_points_actor)};
};
const ny_game_actor_level_up = Game_Actor.prototype.levelUp;
Game_Actor.prototype.levelUp = function() {
ny_game_actor_level_up.call(this);
this._learning_points+=this._learning_points_for_level;
};
Game_Actor.prototype.add_learning_points = function(_val) {
this._learning_points+=_val;
}
Game_Actor.prototype.gain_learning_points = function(_val) {
this._learning_points-=_val;
}
Game_Actor.prototype.get_learning_points = function() {
return this._learning_points;
}
const ny_drawActorSimpleStatus = Window_StatusBase.prototype.drawActorSimpleStatus
Window_StatusBase.prototype.drawActorSimpleStatus = function(actor, x, y){
ny_drawActorSimpleStatus.call(this,actor,x,y);
this.drawText(name_learning_points.toString()+" "+actor._learning_points.toString(), x, y+72, 128, "right");
}
ny_drawBasicInfo = Window_Status.prototype.drawBasicInfo
Window_Status.prototype.drawBasicInfo = function(x, y) {
ny_drawBasicInfo.call(this,x,y);
const lineHeight = this.lineHeight();
this.drawText(name_learning_points.toString()+" "+this._actor._learning_points.toString(), x, y + lineHeight * 1);
};
PluginManager.registerCommand('learning_point', "add_learning_points_for_all", args => {
$gameParty.members().forEach((_party_member) => {
_party_member.add_learning_points(Number(args.points));
})
});
PluginManager.registerCommand('learning_point', "add_learning_points_for_actor", args => {
$gameActors.actor(Number(args.actor_id)).add_learning_points(Number(args.points));
});
////////////////////////////////////SELECT ACTOR//////////////////////////////////////////////
function ny_sceene_actorSelect() {
this.initialize.apply(this);
}
ny_sceene_actorSelect.prototype = Object.create(Scene_MenuBase.prototype);
ny_sceene_actorSelect.prototype.constructor = ny_sceene_actorSelect;
ny_sceene_actorSelect.prototype.initialize = function(){
Scene_MenuBase.prototype.initialize.call(this);
}
ny_sceene_actorSelect.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.open_window();
};
ny_sceene_actorSelect.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._actor_window.activate();
this._actor_window.refresh();
this._actor_window.select(0);
};
ny_sceene_actorSelect.prototype.open_window = function(){
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = Graphics.boxHeight;
this._actor_window = new Window_MenuActor(new Rectangle(wx, wy, ww, wh));
this._actor_window.setHandler("ok", this.onActorOk.bind(this));
this._actor_window.setHandler("cancel", this.onActorCancel.bind(this));
this._actor_window.show();
this.addWindow(this._actor_window);
}
ny_sceene_actorSelect.prototype.onActorOk = function(){
_selected_actor = $gameParty.members()[this._actor_window.index()];
SceneManager.push(ny_sceene_training)
}
ny_sceene_actorSelect.prototype.onActorCancel = function(){
this.popScene()
}
//////////////////////////////////////TRAINING/////////////////////////////
function ny_sceene_training() {
this.initialize.apply(this);
}
ny_sceene_training.prototype = Object.create(Scene_MenuBase.prototype);
ny_sceene_training.prototype.constructor = ny_sceene_training;
ny_sceene_training.prototype.initialize = function(){
Scene_MenuBase.prototype.initialize.call(this);
}
ny_sceene_training.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.open_window();
};
ny_sceene_training.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this.trainwindows.select(0);
this.trainwindows.refresh();
};
ny_sceene_training.prototype.open_window = function(){
this.trainwindows = new ny_window_training();
this.trainwindows.setHandler("ok", this.onTrainingOk.bind(this));
this.trainwindows.setHandler("cancel", this.onTrainingCancel.bind(this));
this.addWindow(this.trainwindows);
this.trainwindows.refresh();
}
ny_sceene_training.prototype.onTrainingOk = function(){
if(type_upgrade == 0){
if(_selected_actor.get_learning_points()>=cost_skills_for_learning[this.trainwindows.index()]&& !_selected_actor.isLearnedSkill(skills_for_learning[this.trainwindows.index()])){
_selected_actor.learnSkill(skills_for_learning[this.trainwindows.index()])
_selected_actor.gain_learning_points(cost_skills_for_learning[this.trainwindows.index()]);
}
}
else{
if(_selected_actor.get_learning_points()>=cost_skills_for_learning[this.trainwindows.index()]){
_selected_actor.addParam(characteristic_name[skills_for_learning[this.trainwindows.index()]],val_skills_for_learning[this.trainwindows.index()])
_selected_actor.gain_learning_points(cost_skills_for_learning[this.trainwindows.index()]);
}
}
this.trainwindows.refresh();
this.trainwindows.activate()
}
ny_sceene_training.prototype.onTrainingCancel = function(){
this.popScene();
}
function ny_window_training() {
this.initialize.apply(this);
}
ny_window_training.prototype = Object.create(Window_Selectable.prototype);
ny_window_training.prototype.constructor = ny_window_training;
ny_window_training.prototype.initialize = function() {
const wx = 100;
const wy = 50;
const ww = Graphics.boxWidth-200;
const wh = Graphics.boxHeight-100;
Window_Selectable.prototype.initialize.call(this, new Rectangle(wx, wy, ww, wh));
this.scrollTo(0, 0);
this.activate();
this.refresh();
}
ny_window_training.prototype.maxItems = function() {
return skills_for_learning.length;
};
ny_window_training.prototype.drawItem = function(index) {
const rect = this.itemLineRect(index);
if(type_upgrade == 0){
this.changePaintOpacity((_selected_actor.get_learning_points()>=cost_skills_for_learning[index]) && !_selected_actor.isLearnedSkill(skills_for_learning[index]));
this.drawItemName($dataSkills[skills_for_learning[index]], rect.x, rect.y, rect.width);
}else{
this.changePaintOpacity((_selected_actor.get_learning_points()>=cost_skills_for_learning[index]));
this.drawParamName(rect.x, rect.y, rect.width, characteristic_name[skills_for_learning[index]],index);
}
this.drawItemNumber(index, rect.x, rect.y, rect.width);
this.changePaintOpacity(1);
}
ny_window_training.prototype.drawParamName = function(x, y, width, paramId,index) {
this.changeTextColor(ColorManager.systemColor());
this.drawText(TextManager.param(paramId)+" +"+String(val_skills_for_learning[index]), x, y, width);
};
ny_window_training.prototype.drawItemNumber = function(index, x, y, width) {
var _skill_cost_string = String(cost_skills_for_learning[index]);
this.drawText(name_learning_points+":", x, y, width - this.textWidth("000"), "right");
this.drawText(_skill_cost_string, x, y, width, "right");
}
PluginManager.registerCommand('learning_point', "open_skill_window", args => {
type_upgrade = 0
skills_for_learning = [];
cost_skills_for_learning = [];
skills_for_learning = args.skills.split(';');
cost_skills_for_learning = args.cost_skills.split(';');
for (let i = 0; i < skills_for_learning.length; i++) {
skills_for_learning[i] = Number(skills_for_learning[i]);
cost_skills_for_learning[i] = Number(cost_skills_for_learning[i]);
}
SceneManager.push(ny_sceene_actorSelect);
});
PluginManager.registerCommand('learning_point', "open_characterisctic_window", args => {
type_upgrade = 1;
skills_for_learning = [];
cost_skills_for_learning = [];
val_skills_for_learning = [];
skills_for_learning = args.characterisctics.split(';');
cost_skills_for_learning = args.cost_characterisctics.split(';');
val_skills_for_learning = args.val_characterisctics.split(';');
for (let i = 0; i < cost_skills_for_learning.length; i++) {
cost_skills_for_learning[i] = Number(cost_skills_for_learning[i]);
val_skills_for_learning[i] = Number(val_skills_for_learning[i]);
}
SceneManager.push(ny_sceene_actorSelect);
});
Социальные закладки